package cn.com.edue.maldemo;

import java.util.ArrayList;
import java.util.List;

import com.mathworks.toolbox.javabuilder.MWException;
import com.mathworks.toolbox.javabuilder.MWNumericArray;

import RAGA_PP.RAGA_PPC;

public class MalDemo2 {
	
	public static void main(String[] args) {
		
		try {
			//1.输入参数准备
			double N=10;
			//原始数据
			Double[][] inputValues = new Double[][]{
				{8.00,6.11,6.00,3.00,0.022,6.44,6.00,6.67,0.166,6.00,1.000,7.78}, 
				{5.56,5.89,6.67,3.00,0.019,7.44,6.33,7.33,0.847,7.33,0.615,7.56}, 
				{7.33,6.56,6.00,7.00,0.049,6.89,7.00,7.78,0.588,6.67,0.889,7.78}, 
				{4.00,5.78,5.44,2.00,0.018,7.00,5.89,6.78,0.463,6.22,0.833,8.11}, 
				{7.89,6.00,7.11,3.00,0.039,6.89,6.00,7.00,0.827,7.00,0.800,7.11}, 
				{5.89,7.33,6.78,3.00,0.024,7.00,6.67,6.56,0.938,7.33,0.833,6.89}, 
				{7.89,7.33,7.78,5.00,0.033,7.56,7.33,8.00,0.678,7.56,0.778,7.78}, 
				{6.22,6.44,6.78,2.00,0.017,7.56,7.22,7.56,0.629,7.78,0.800,7.67}, 
				{5.78,8.00,7.33,4.00,0.038,7.89,7.67,8.00,0.933,7.78,0.727,8.11}, 
				{7.11,7.56,7.67,6.00,0.039,7.89,7.56,7.78,0.958,7.89,0.769,8.56}, 
				{8.22,6.89,6.33,3.00,0.016,8.00,6.22,7.67,0.951,8.00,0.769,8.44}, 
				{6.44,7.00,7.56,4.00,0.030,7.78,8.11,7.67,1.436,7.89,0.722,8.22}, 
				{8.33,5.67,5.44,4.00,0.032,6.11,5.78,6.78,0.697,6.22,0.700,7.67}, 
				{7.89,6.67,6.67,3.00,0.013,7.67,7.00,7.67,0.696,7.56,0.667,7.89}, 
				{5.00,5.89,5.89,3.00,0.015,6.78,6.33,6.89,0.750,6.33,0.917,7.44}, 
				{7.44,6.11,6.11,4.00,0.028,7.00,6.89,6.89,0.594,6.67,1.000,7.67}, 
				{8.67,6.33,5.78,5.00,0.038,5.89,6.11,6.11,0.584,6.33,0.750,7.44}, 
				{7.89,6.11,6.00,5.00,0.028,7.00,6.22,7.11,0.744,6.56,0.900,7.78}, 
				{7.56,6.56,6.67,4.00,0.025,7.11,6.89,7.22,0.646,7.33,0.818,7.78}, 
				{8.44,5.89,6.56,6.00,0.017,7.56,6.56,8.33,0.481,8.00,0.818,8.00}, 
				{7.67,7.67,7.89,7.00,0.047,8.11,8.22,7.89,1.285,8.33,0.667,8.22}, 
				{6.22,6.56,7.22,3.00,0.015,6.89,7.67,6.89,0.973,7.56,0.714,7.78}, 
				{8.33,6.44,7.89,5.00,0.016,6.67,7.56,6.78,0.425,7.00,0.857,7.67}, 
				{7.89,6.11,6.44,3.00,0.018,7.33,6.67,7.44,0.348,7.00,0.857,7.78}, 
				{8.22,5.33,6.00,5.00,0.013,7.22,7.00,6.89,0.560,7.00,0.800,7.44}, 
				{7.89,6.67,5.67,2.00,0.042,6.00,6.44,5.78,0.337,6.11,1.000,7.44}, 
				{6.67,8.00,7.00,4.00,0.027,7.56,7.67,7.56,0.527,7.22,0.625,8.11}, 
				{6.78,5.67,6.78,2.00,0.019,7.00,6.56,7.11,0.661,7.11,0.727,7.67}, 
				{5.22,6.89,5.56,1.00,0.019,8.22,5.78,8.56,1.130,8.33,0.867,8.22}, 
				{5.33,6.78,5.67,2.00,0.014,8.11,5.56,8.56,1.210,8.22,0.588,8.00}
			};
			MWNumericArray x = new MWNumericArray(inputValues);
			if(5>3) {
				return;
			}
			double Pc=0.8;
			double Pm=0.2;
			double M=10;
			double DaiNo=2;
			double Ci=20;
			double ads=1;
			double ac = 10^(-6);
			double exV = 5;
			double par_Q = 1;
			double coe_Q = 0.1;
			int Run_No = 10; 
			//double Max_max_No = 1:12;//1到12的向量
			int[] Max_max_No = {1,2,3,4,5,6,7,8,9,10,11,12};
			double[] Min_min_No= {};
			
			RAGA_PPC ppc = new RAGA_PPC();
			//2.执行预处理函数
			Object[] dataprocess = ppc.dataprocess(2, x,Max_max_No,Min_min_No);
			Object xx = dataprocess[0];
			Object n = dataprocess[1];
			System.out.println("xx="+xx);
			System.out.println("n="+n);
			
			//3.设置随机规则
			//ppc.suijikongzhi();
			//4.根据输入执行循环
			List<Object[]> list = new ArrayList<Object[]>();
			for(int i = 1;i<=Run_No;i++) {
				System.out.println("第"+i+"次循环开始=================");
				
				Object[] raga = ppc.RAGA(7, N,n,xx,Pc,Pm,M,DaiNo,Ci,ads,ac,exV,par_Q,coe_Q);
				list.add(raga);
				
				System.out.println("第"+i+"次循环输出1="+raga[0]);//a 单个值,需要求最大
				System.out.println("第"+i+"次循环输出2="+raga[1]);//b Run_No行,n列
				System.out.println("第"+i+"次循环输出3="+raga[2]);
				System.out.println("第"+i+"次循环输出4="+raga[3]);
				System.out.println("第"+i+"次循环输出5="+raga[4]);//t3 每次multab运行的时间
				System.out.println("第"+i+"次循环输出6="+raga[5]);//index 元胞(三位数组)
				System.out.println("第"+i+"次循环输出7="+raga[6]);//fv1         元胞
				
				
				System.out.println("第"+i+"次循环结束=================");
			}
			
			//5.计算循环结果
			//TODO list中求出最大a
			//TODO 根据index和fv1输出折线图，index是x,fv1是y

			
		} catch (MWException e) {
			e.printStackTrace();
		}
		
		
	}
public static void test1() {
		
		try {
			//1.输入参数准备
			double N=10;
			//原始数据
			Double[][] inputValues = new Double[][]{
				{8.00,6.11,6.00,3.00,0.022,6.44,6.00,6.67,0.166,6.00,1.000,7.78}, 
				{5.56,5.89,6.67,3.00,0.019,7.44,6.33,7.33,0.847,7.33,0.615,7.56}, 
				{7.33,6.56,6.00,7.00,0.049,6.89,7.00,7.78,0.588,6.67,0.889,7.78}, 
				{4.00,5.78,5.44,2.00,0.018,7.00,5.89,6.78,0.463,6.22,0.833,8.11}, 
				{7.89,6.00,7.11,3.00,0.039,6.89,6.00,7.00,0.827,7.00,0.800,7.11}, 
				{5.89,7.33,6.78,3.00,0.024,7.00,6.67,6.56,0.938,7.33,0.833,6.89}, 
				{7.89,7.33,7.78,5.00,0.033,7.56,7.33,8.00,0.678,7.56,0.778,7.78}, 
				{6.22,6.44,6.78,2.00,0.017,7.56,7.22,7.56,0.629,7.78,0.800,7.67}, 
				{5.78,8.00,7.33,4.00,0.038,7.89,7.67,8.00,0.933,7.78,0.727,8.11}, 
				{7.11,7.56,7.67,6.00,0.039,7.89,7.56,7.78,0.958,7.89,0.769,8.56}, 
				{8.22,6.89,6.33,3.00,0.016,8.00,6.22,7.67,0.951,8.00,0.769,8.44}, 
				{6.44,7.00,7.56,4.00,0.030,7.78,8.11,7.67,1.436,7.89,0.722,8.22}, 
				{8.33,5.67,5.44,4.00,0.032,6.11,5.78,6.78,0.697,6.22,0.700,7.67}, 
				{7.89,6.67,6.67,3.00,0.013,7.67,7.00,7.67,0.696,7.56,0.667,7.89}, 
				{5.00,5.89,5.89,3.00,0.015,6.78,6.33,6.89,0.750,6.33,0.917,7.44}, 
				{7.44,6.11,6.11,4.00,0.028,7.00,6.89,6.89,0.594,6.67,1.000,7.67}, 
				{8.67,6.33,5.78,5.00,0.038,5.89,6.11,6.11,0.584,6.33,0.750,7.44}, 
				{7.89,6.11,6.00,5.00,0.028,7.00,6.22,7.11,0.744,6.56,0.900,7.78}, 
				{7.56,6.56,6.67,4.00,0.025,7.11,6.89,7.22,0.646,7.33,0.818,7.78}, 
				{8.44,5.89,6.56,6.00,0.017,7.56,6.56,8.33,0.481,8.00,0.818,8.00}, 
				{7.67,7.67,7.89,7.00,0.047,8.11,8.22,7.89,1.285,8.33,0.667,8.22}, 
				{6.22,6.56,7.22,3.00,0.015,6.89,7.67,6.89,0.973,7.56,0.714,7.78}, 
				{8.33,6.44,7.89,5.00,0.016,6.67,7.56,6.78,0.425,7.00,0.857,7.67}, 
				{7.89,6.11,6.44,3.00,0.018,7.33,6.67,7.44,0.348,7.00,0.857,7.78}, 
				{8.22,5.33,6.00,5.00,0.013,7.22,7.00,6.89,0.560,7.00,0.800,7.44}, 
				{7.89,6.67,5.67,2.00,0.042,6.00,6.44,5.78,0.337,6.11,1.000,7.44}, 
				{6.67,8.00,7.00,4.00,0.027,7.56,7.67,7.56,0.527,7.22,0.625,8.11}, 
				{6.78,5.67,6.78,2.00,0.019,7.00,6.56,7.11,0.661,7.11,0.727,7.67}, 
				{5.22,6.89,5.56,1.00,0.019,8.22,5.78,8.56,1.130,8.33,0.867,8.22}, 
				{5.33,6.78,5.67,2.00,0.014,8.11,5.56,8.56,1.210,8.22,0.588,8.00}
			};
			MWNumericArray x = new MWNumericArray(inputValues);
			
			double Pc=0.8;
			double Pm=0.2;
			double M=10;
			double DaiNo=2;
			double Ci=20;
			double ads=1;
			double ac = 10^(-6);
			double exV = 5;
			double par_Q = 1;
			double coe_Q = 0.1;
			int Run_No = 10; 
			//double Max_max_No = 1:12;//1到12的向量
			int[] Max_max_No = {1,2,3,4,5,6,7,8,9,10,11,12};
			double[] Min_min_No= {};
			
			RAGA_PPC ppc = new RAGA_PPC();
			//2.执行预处理函数
			Object[] dataprocess = ppc.dataprocess(2, x,Max_max_No,Min_min_No);
			Object xx = dataprocess[0];
			Object n = dataprocess[1];
			System.out.println("xx="+xx);
			System.out.println("n="+n);
			
			//3.设置随机规则
			//ppc.suijikongzhi();
			//4.根据输入执行循环
			List<Object[]> list = new ArrayList<Object[]>();
			for(int i = 1;i<=Run_No;i++) {
				System.out.println("第"+i+"次循环开始=================");
				
				Object[] raga = ppc.RAGA(7, N,n,xx,Pc,Pm,M,DaiNo,Ci,ads,ac,exV,par_Q,coe_Q);
				list.add(raga);
				
				System.out.println("第"+i+"次循环输出1="+raga[0]);//a 单个值,需要求最大
				System.out.println("第"+i+"次循环输出2="+raga[1]);//b Run_No行,n列
				System.out.println("第"+i+"次循环输出3="+raga[2]);
				System.out.println("第"+i+"次循环输出4="+raga[3]);
				System.out.println("第"+i+"次循环输出5="+raga[4]);//t3 每次multab运行的时间
				System.out.println("第"+i+"次循环输出6="+raga[5]);//index 元胞(三位数组)
				System.out.println("第"+i+"次循环输出7="+raga[6]);//fv1         元胞
				
				
				System.out.println("第"+i+"次循环结束=================");
			}
			
			
			//5.计算循环结果
			
//			Object[] main = main1.main(7,N,array,Pc,Pm,M,DaiNo,Ci,ads,ac,exV,par_Q,coe_Q,Run_No,Max_max_No,Min_min_No);
//			System.out.println("返回参数1="+main[0]);
//			System.out.println("返回参数2="+main[1]);
//			System.out.println("返回参数3="+main[2]);
//			System.out.println("返回参数4="+main[3]);
//			System.out.println("返回参数5="+main[4]);
//			MWNumericArray return5 = (MWNumericArray) main[4];
//			//return5.get
//			System.out.println("返回参数6="+main[5]);
//			System.out.println("返回参数7="+main[6]);
			
		} catch (MWException e) {
			e.printStackTrace();
		}
		
		
	}

}
